import Tools from '@/utils/Tools.js'
import copy from 'copy-to-clipboard';
const actionList = () => {
	return {
		shareActionList: ['生成商品海报', '发送给朋友'],
		show: false,
		cancelWithMask: true,
		cancelText: '关闭',
		actions: [{
				name: '生成商品海报',
				className: 'action-class',
				loading: false
			},
			// #ifdef MP
			{
				name: '发送给朋友',
				openType: 'share'
			},
			// #endif
			// #ifdef H5
			{
				name: '发送给朋友',
				className: 'action-class',
				loading: false
			}
			// #endif
		],
		// 商品海报
		showPopup: false
	}
}
const send = (shareUrl) => {
	// #ifdef H5
	copy(shareUrl);
	if (Tools.isWechat()) {
		Tools.showError('分享链接已复制,您还可以点击右上角分享')
	} else {
		uni.showToast({
			title: '分享链接已复制'
		})
	}
	// #endif
	// #ifndef H5
	uni.setClipboardData({
		data: shareUrl,
		success: () => {
			uni.showToast({
				title: '分享链接已复制'
			})
		}
	});
	// #endif
}

export default {
	send,
	actionList
}
